package com.foreveross.service;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.foreveross.dao.HrBusinessDAO;
import com.foreveross.vo.HrBusiness;
import com.foreveross.vo.HrCode;

@Service("hrBusinessService")
@Transactional
public class HrBusinessService extends BaseService {

	@Resource
	public HrBusinessDAO hrBusinessDAO;

	public long getHrBusinessListCount(String userId,String name,String houseId) throws Exception{
		return hrBusinessDAO.getHrBusinessListCount(userId,name,houseId);
	}

	public List<HrBusiness> getHrBusinessList(String userId,String name,String houseId, int pageIndex,
			int pageSize) throws Exception{
		
		return hrBusinessDAO.getHrBusinessList(userId,name, houseId,pageIndex,pageSize);
	}

	public HrBusiness getHrBusinessById(String id) throws Exception{
		
		return (HrBusiness) hrBusinessDAO.findById(HrBusiness.class, id);
	}

	public List<HrBusiness> getBusinessSelect(String userId,String houseId,String id, int pageIndex,
			int pageSize) throws Exception{
		List<HrBusiness> hrBusinessList = hrBusinessDAO.getHrBusinessList(userId,null, houseId,pageIndex,pageSize);
		if (id != null && !"".equals(id)) {
			for (HrBusiness hrBusiness : hrBusinessList) {
				if (hrBusiness.getId().equals(id))
					hrBusiness.setSelected(true);
			}
		}
		return hrBusinessList;
	}



}
